package com.xiaoyu.tool.entity.order;

import com.xiaoyu.tool.entity.common.AbstractEntity;
import com.xiaoyu.tool.enums.order.OrderPayType;
import com.xiaoyu.tool.enums.order.OrderStatus;
import com.xiaoyu.tool.enums.order.OrderType;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

@Entity
@Table(name = "orders")
@Data
@EqualsAndHashCode(callSuper = true)
public class Order extends AbstractEntity {

    @Column
    private Long userId;

    @Column
    @Enumerated(EnumType.STRING)
    private OrderStatus status = OrderStatus.等待支付;

    @Column
    @Temporal(TemporalType.TIMESTAMP)
    private Date finishedAt;

    @Column
    @Temporal(TemporalType.TIMESTAMP)
    private Date canceledAt; //取消时间

    @Column
    @Temporal(TemporalType.TIMESTAMP)
    private Date payAt;

    @Column
    @Temporal(TemporalType.TIMESTAMP)
    private Date refundAt;

    @Column
    @Temporal(TemporalType.TIMESTAMP)
    private Date loseAt;//失效时间

    @Column
    private String orderNo;

    @Column
    private String refundNo;//退款单号

    @Column
    private String reason;//退款理由

    @Column
    private String content; //拒绝退款原因

    @Column
    @Enumerated(EnumType.STRING)
    private OrderType orderType = OrderType.普通订单;

    @Column
    private BigDecimal freightPrice = new BigDecimal(0);

    @Column
    private Boolean isFreightFree = false; //是否免运费

    @Column
    private BigDecimal payMoney = new BigDecimal(0);

    @Column
    private BigDecimal discount = new BigDecimal(0);

    @Column
    private Boolean isMyselfPick = false; //是否自提（上门取件，免运费）

    @Column
    @Enumerated(EnumType.STRING)
    private OrderPayType orderPayType = OrderPayType.微信;

    @Column
    private Boolean isUseIntegral = false;  //是否使用积分付款
}
